package com.jic.order.impl;

import com.jic.common.base.vo.PageResult;
import com.jic.order.entity.OrderBaleDetail;
import com.jic.order.manage.request.OrderBaleDetailRequest;
import com.jic.order.manage.response.OrderBaleDetailResponse;
import com.jic.order.mapper.OrderBaleDetailMapper;
import com.jic.order.service.OrderBaleDetailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 包裹明细表
 * @author :
 * @email :
 * @since : 2020-03-03 11:43:27
 * @version : v1.0.0
 */
@Service
public class OrderBaleDetailServiceImpl implements OrderBaleDetailService {

    @Autowired
    private OrderBaleDetailMapper orderBaleDetailMapper;

    @Override
    public long insert(OrderBaleDetail orderBaleDetail) {
        long flag = orderBaleDetailMapper.insert(orderBaleDetail);
        return flag;
    }

    @Override
    public long delete(Long id) {
        return orderBaleDetailMapper.delete(id);
    }

    @Override
    public long update(OrderBaleDetail orderBaleDetail) {
        return orderBaleDetailMapper.update(orderBaleDetail);
    }

    @Override
    public OrderBaleDetail queryByPrimaryKey(Long id){
        return orderBaleDetailMapper.queryByPrimaryKey(id);
    }

    @Override
    public List<OrderBaleDetail> query(OrderBaleDetail orderBaleDetail){
        return orderBaleDetailMapper.query(orderBaleDetail);
    }

    @Override
    public PageResult<OrderBaleDetailResponse> queryPage(OrderBaleDetailRequest obdr) {
        //计算下标
        int startIndex = (obdr.getStart() - 1) * obdr.getLimit();
        List<OrderBaleDetail> list = orderBaleDetailMapper.queryPage(startIndex, obdr);
        long count = orderBaleDetailMapper.queryPageCount(obdr);
        PageResult pageResult = new PageResult();
        pageResult.setRows(list);
        pageResult.setTotal(count);
        return pageResult;
    }
}
